#include <Babylon/Graphics/Platform.h>
#include "DeviceImpl.h"

#include <window_manager/oh_display_manager.h>

namespace Babylon::Graphics
{
    void DeviceImpl::ConfigureBgfxPlatformData(bgfx::PlatformData& pd, WindowT window)
    {
        pd.nwh = window;
    }

    void DeviceImpl::ConfigureBgfxRenderType(bgfx::PlatformData& pd, bgfx::RendererType::Enum& renderType)
    {
        // on Android, having no window or context set the renderer API to no op.
        if (!pd.nwh && !pd.context)
        {
            renderType = bgfx::RendererType::Noop;
        }
    }

    float DeviceImpl::GetDevicePixelRatio(WindowT)
    {
        // In Harmony, the baseline DPI is 160dpi.
        int32_t densityDpi{};
        OH_NativeDisplayManager_GetDefaultDisplayDensityDpi(&densityDpi);
        return static_cast<float>(densityDpi) / 160.0f;
    }
}
